﻿using Mahanet.Abyss.PathCalculation;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace motion
{
    public class DrawingPointLayer : BaseLayer
    {
        public Coordinate2D SelectedPoint { get; private set; }
        public int PointSize { get; set; }
		public Brush DrawingBrush { get; private set; }

        public DrawingPointLayer(Control parentController, Color pointColor, int pointSize = 5) : base(parentController)
        {
            PointSize = pointSize;
            ParentController.MouseClick += ParentController_MouseClick;
			DrawingBrush = new SolidBrush(pointColor);
        }

        void ParentController_MouseClick(object sender, MouseEventArgs e)
        {
            SelectedPoint = new Coordinate2D(e.X, e.Y);
        }

        protected override void OnLayerPaint(System.Windows.Forms.PaintEventArgs pe)
        {
            if (SelectedPoint != null)
            {
                pe.Graphics.FillEllipse(DrawingBrush, 
                                        (int)SelectedPoint.X,
                                        ParentController.Height - PointSize - (int)SelectedPoint.Y,
                                        PointSize,
                                        PointSize);
            }
        }
    }
}
